#!/bin/bash

# usage  ./run_in_host.sh $order
port=8080
imgName=cluster_script



# http://stackoverflow.com/questions/13322485/how-to-i-get-the-primary-ip-address-of-the-local-machine-on-linux-and-os-x
myip=
while IFS=$': \t' read -a line ;do
    [ -z "${line%inet}" ] && ip=${line[${#line[1]}>4?1:2]} &&
        [ "${ip#127.0.0.1}" ] && myip=$ip
  done< <(LANG=C /sbin/ifconfig)

# echo $myip

# --name node$1 \
docker run -ti \
-p 2181 -p 2888 -p 3888 -p 9092 -p 8080 \
$imgName \
/bin/bash -c "/usr/bin/node /tmp/reg_cli.js server=$myip:$port order=$1 " 